﻿Imports WoWArmoryParser
Imports System.IO
Imports System.IO.StreamWriter
Imports System.IO.StreamReader

Public Class Form1

    'Written by C Lacey
    'Created using Visual Studio 2008
    'Utilizing the WoW Armory Parser
    'Released under the Microsoft Reciprocal License (Ms-RL)

    'Character Variables
    Dim c_name As String    'Character name
    Dim c_race As Integer   'Character race
    Dim c_class As Integer  'Character class
    Dim faction As Integer  'Facterion
    Dim health As Integer   'Health value
    Dim spell As Integer    'Mana value
    Dim guild As String     'Guild name
    Dim gender As Integer   'Character gender (male or female)
    Dim realm As Integer    'Realm (server)
    Dim reg_click As Integer    'Saves the value of comboRegion
    Dim char_realm As String    'Saves the value of either ComboEU or comboUSA
    Dim char_sheet As String    'Contains the URL to allow the user to view the Blizzard weaponry page
    Dim load_sheet As Boolean   'Sets whether a Viewer Character File has been loaded

    'Weapon Variables
    Dim weap_name(20) As String 'Sets the Weaponary Name
    Dim weap_icon(20) As String 'Sets blizzard icon used for weaonary
    Dim weap_id(20) As Integer  'Set the weapon id used by blizzard
    ' *Denotes obsolete - will be removed ASAP


    'File system Variables
    Dim file_char_name As String    'Varable used for loading and saving character information
    Dim file_char_region As String    'Varable used for loading and saving character information
    Dim file_char_realm As String    'Varable used for loading and saving character information
    Dim regionstr As String    'Varable used for loading and saving character information

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Show()
        comboRegion.SelectedIndex = 0
        ToolStripLabel6.Text = ""
        lnkinfo.Text = ""
        tslblOperation.Text = ""
        txtName.Focus()
        ToolStrip1.Width = Me.Width
        Label3.Text = ""
        Label4.Text = ""
    End Sub

    Private Sub comboRegion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboRegion.SelectedIndexChanged
        If comboRegion.SelectedIndex = 0 Then
            comboEU.Visible = True
            comboUSA.Visible = False
            comboEU.SelectedIndex = 0
        ElseIf comboRegion.SelectedIndex = 1 Then
            comboEU.Visible = False
            comboUSA.Visible = True
            comboUSA.SelectedIndex = 0
        ElseIf comboRegion.SelectedIndex = 2 Then
            MsgBox("Not implemented yet", MsgBoxStyle.Exclamation, "Viewer")
            clear()
            txtName.Focus()
            Exit Sub
        ElseIf comboRegion.SelectedIndex = 3 Then
            MsgBox("Not implemented yet", MsgBoxStyle.Exclamation, "Viewer")
            clear()
            txtName.Focus()
            Exit Sub
        ElseIf comboRegion.SelectedIndex = 4 Then
            MsgBox("Not implemented yet", MsgBoxStyle.Exclamation, "Viewer")
            clear()
            txtName.Focus()
            Exit Sub
        End If
    End Sub

    Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Trim(txtName.Text) = "" Then
            clear()
            txtName.Focus()
            Exit Sub
        End If
        txtName.Text = StrConv(txtName.Text, VbStrConv.ProperCase)
        If comboRegion.SelectedIndex = 0 Then
            comboEU.Visible = True
            char_realm = Trim(comboEU.SelectedItem)
            reg_click = 0
        End If
        If comboRegion.SelectedIndex = 1 Then
            comboUSA.Visible = True
            char_realm = Trim(comboUSA.SelectedItem)
            reg_click = 1
        End If
        get_character_information()
    End Sub

    Private Sub comboEU_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        txtName.Text = StrConv(txtName.Text, VbStrConv.ProperCase)
    End Sub

    Private Sub comboUSA_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        txtName.Text = StrConv(txtName.Text, VbStrConv.ProperCase)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Application.Exit()
    End Sub

    'Set Character information

    Private Sub get_character_information()

        Dim wow_icon As String
        Dim class_info As String
        Dim class_icon As String
        Try
            Dim character As CharacterInfo = ArmoryParser.GetCharacter(reg_click, Trim(char_realm), file_char_name)
            If load_sheet = True Then
                txtName.Text = file_char_name
            End If
            tslblOperation.Text = "Compiling Character Information"
            c_name = Trim(txtName.Text)
            c_race = character.Race
            c_class = character.Race
            If character.Faction = FactionEnum.Alliance Then
                picHorde.Visible = False
                picAlliance.Visible = True
            ElseIf character.Faction = FactionEnum.Horde Then
                picHorde.Visible = True
                picAlliance.Visible = False
            End If
            If character.CharacterClass = 11 Then
                class_info = "druid.jpg"
            ElseIf character.CharacterClass = 3 Then
                class_info = "hunter.jpg"
            ElseIf character.CharacterClass = 8 Then
                class_info = "mage.jpg"
            ElseIf character.CharacterClass = 2 Then
                class_info = "paladin.jpg"
            ElseIf character.CharacterClass = 5 Then
                class_info = "priest.jpg"
            ElseIf character.CharacterClass = 4 Then
                class_info = "rouge.jpg"
            ElseIf character.CharacterClass = 7 Then
                class_info = "shaman.jpg"
            ElseIf character.CharacterClass = 9 Then
                class_info = "warlock.jpg"
            ElseIf character.CharacterClass = 1 Then
                class_info = "warrior.jpg"
            End If
            lblLevel.Text = "Level:" & character.Level
            ProgressBar1.Value = Val(character.Level)
            lblGuild.Text = "Guild: " & character.GuildName
            lblAchieve.Text = "Achievements:" & character.AchievementPoints & " of 11635"
            ProgressBar2.Value = character.AchievementPoints
            'Statistics Start
            lblHealth.Text = "Health:" & Str(character.HealthBar.Total)
            lblSpell.Text = "Mana:" & Str(character.SecondBar.Total)
            lblStrength.Text = "Strength:" & Str(character.BaseStats.Strength)
            lblAgility.Text = "Agility:" & Str(character.BaseStats.Agility)
            lblStamina.Text = "Stamina:" & Str(character.BaseStats.Stamina)
            lblIntellect.Text = "Intellect:" & Str(character.BaseStats.Intellect)
            lblSpirit.Text = "Spirit:" & Str(character.BaseStats.Spirit)
            lblArmor.Text = "Armor:" & Str(character.BaseStats.Armor)
            'Ranged Statistics
            lblDamageRanged.Text = "Damage: " & character.Ranged.Weapon.Damage.Max
            lblSpeed.Text = "Speed: " & character.Ranged.Weapon.Speed.Value
            lblPower.Text = "Power: " & character.Ranged.AttackPower.Effective
            lblHitRatingRanged.Text = "Hit Rating: " & character.Ranged.Hit.Rating
            lblCritChanceRanged.Text = "Crit Chance: " & character.Ranged.CritChance.Percent & "%"
            'Spell Statistics
            lblDamage.Text = "Bonus Damage: " & character.Spell.Penetration.Value
            lblHealing.Text = "Bonus Healing: " & character.Spell.HealingBonus
            lblHit.Text = "Hit Rating:" & character.Spell.HitRating.Rating
            lblCrit.Text = "Crit Chance: " & character.Spell.CritRating
            lblHaste.Text = "Haste Rating: " & character.Spell.HasteRating.Percent & "%"
            lblMana.Text = "Mana Regen: " & character.Spell.ManaRegen.WhileNotCasting
            'Defense Statistics
            lblArmorDef.Text = "Armor:" & character.Defense.Armor.Effective
            lblDefense.Text = "Defense:" & character.Defense.Defense.Total
            lblDodge.Text = "Dodge:" & character.Defense.Dodge.Percent
            lblParry.Text = "Parry:" & character.Defense.Parry.Percent
            lblBlock.Text = "Block:" & character.Defense.Block.Percent
            lblResilience.Text = "Resilience:" & character.Defense.Resilience.Value
            'Melee Statistics
            lblDamageMelee.Text = "Damage:" & character.Melee.MainHand.Damage.Max
            lblSpeedMelee.Text = "Speed:" & character.Melee.MainHand.Speed.Rating
            lblPowerMelee.Text = "Power:" & character.Melee.AttackPower.Base
            lblHitRatingMelee.Text = "Hit Rating:" & character.Melee.Hit.Rating
            lblCritChanceMelee.Text = "Crit Chance:" & character.Melee.CritChance.Percent
            lblExpertise.Text = "Expertise:" & character.Melee.Expertise.Value
            'End Stats
            char_sheet = character.ArmoryWebPath.AbsoluteUri
            ToolStripLabel6.Text = Trim(txtName.Text) & "'s Character Sheet"
            class_icon = "http://eu.wowarmory.com/_images/icons/class/" & character.CharacterClass & ".gif"
            wow_icon = "http://eu.wowarmory.com/_images/portraits/wow-default/" & character.Gender & "-" & character.Race & "-" & character.CharacterClass & ".gif"
            If character.Level >= 70 And character.Level <= 79 Then
                wow_icon = "http://eu.wowarmory.com/_images/portraits/wow-70/" & character.Gender & "-" & character.Race & "-" & character.CharacterClass & ".gif"
            ElseIf character.Level >= 80 Then
                wow_icon = "http://eu.wowarmory.com/_images/portraits/wow-80/" & character.Gender & "-" & character.Race & "-" & character.CharacterClass & ".gif"
            End If
            Application.DoEvents()
            picClass.ImageLocation = class_icon
            picRace.ImageLocation = wow_icon
            Label3.Text = character.Race.ToString
            Label4.Text = character.CharacterClass.ToString
            Application.DoEvents()
            ToolStripButton2.Enabled = False
            tslblOperation.Text = "Compiling Armor Information"
            set_armory(reg_click, Trim(char_realm), Trim(txtName.Text))
            Application.DoEvents()
            tslblOperation.Text = Trim(txtName.Text) & "'s Armory View"
            show_armory()
            create_html(Trim(char_realm), Trim(txtName.Text), reg_click)
            WebBrowser1.Visible = True
            WebBrowser2.Visible = True
            ToolStripButton2.Enabled = True
        Catch
        End Try
    End Sub

    'Set Armory Information

    Private Sub set_armory(ByVal server As Integer, ByVal realm As String, ByVal ch_name As String)
        Try
            Dim character As CharacterInfo = ArmoryParser.GetCharacter(server, Trim(realm), Trim(ch_name))
            'Set Head
            Try
                weap_name(0) = character.EquippedItems.Slots.Head.Name
                weap_icon(0) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Head.Icon + ".jpg"
                weap_id(0) = character.EquippedItems.Slots.Head.ID
            Catch
            End Try
            'Set necklace
            Try
                weap_name(1) = character.EquippedItems.Slots.Necklace.Name
                weap_icon(1) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Necklace.Icon + ".jpg"
                weap_id(1) = character.EquippedItems.Slots.Necklace.ID
            Catch
            End Try
            'Set shoulders
            Try
                weap_name(2) = character.EquippedItems.Slots.Shoulders.Name
                weap_icon(2) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Shoulders.Icon + ".jpg"
                weap_id(2) = character.EquippedItems.Slots.Shoulders.ID
            Catch
            End Try
            'Set back
            Try
                weap_name(3) = character.EquippedItems.Slots.Back.Name
                weap_icon(3) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Back.Icon + ".jpg"
                weap_id(3) = character.EquippedItems.Slots.Back.ID
            Catch
            End Try
            'Set chest
            Try
                weap_name(4) = character.EquippedItems.Slots.Chest.Name
                weap_icon(4) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Chest.Icon + ".jpg"
                weap_id(4) = character.EquippedItems.Slots.Chest.ID
            Catch
            End Try
            'Set shirt
            Try
                weap_name(5) = character.EquippedItems.Slots.Shirt.Name
                weap_icon(5) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Shirt.Icon + ".jpg"
                weap_id(5) = character.EquippedItems.Slots.Shirt.ID
            Catch
            End Try
            'Set tabard
            Try
                weap_name(6) = character.EquippedItems.Slots.Tabard.Name
                weap_icon(6) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Tabard.Icon + ".jpg"
                weap_id(6) = character.EquippedItems.Slots.Tabard.ID
            Catch
            End Try
            'Set wrist
            Try
                weap_name(7) = character.EquippedItems.Slots.Wrists.Name
                weap_icon(7) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Wrists.Icon + ".jpg"
                weap_id(7) = character.EquippedItems.Slots.Wrists.ID
            Catch
            End Try
            'Set hands
            Try
                weap_name(8) = character.EquippedItems.Slots.Hands.Name
                weap_icon(8) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Hands.Icon + ".jpg"
                weap_id(8) = character.EquippedItems.Slots.Hands.ID
            Catch
            End Try
            'Set waist
            Try
                weap_name(9) = character.EquippedItems.Slots.Waist.Name
                weap_icon(9) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Waist.Icon + ".jpg"
                weap_id(9) = character.EquippedItems.Slots.Waist.ID
            Catch
            End Try
            'Set legs
            Try
                weap_name(10) = character.EquippedItems.Slots.Legs.Name
                weap_icon(10) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Legs.Icon + ".jpg"
                weap_id(10) = character.EquippedItems.Slots.Legs.ID
            Catch
            End Try
            'Set feet
            Try
                weap_name(11) = character.EquippedItems.Slots.Feet.Name
                weap_icon(11) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Feet.Icon + ".jpg"
                weap_id(11) = character.EquippedItems.Slots.Feet.ID
            Catch
            End Try
            'Set ring1
            Try
                weap_name(12) = character.EquippedItems.Slots.Ring1.Name
                weap_icon(12) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Ring1.Icon + ".jpg"
                weap_id(12) = character.EquippedItems.Slots.Ring1.ID
            Catch
            End Try
            'Set wrist
            Try
                weap_name(13) = character.EquippedItems.Slots.Ring2.Name
                weap_icon(13) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Ring2.Icon + ".jpg"
                weap_id(13) = character.EquippedItems.Slots.Ring2.ID
            Catch
            End Try
            'Set trinket1
            Try
                weap_name(14) = character.EquippedItems.Slots.Trinket1.Name
                weap_icon(14) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Trinket1.Icon + ".jpg"
                weap_id(14) = character.EquippedItems.Slots.Trinket1.ID
            Catch
            End Try
            'Set trinket2
            Try
                weap_name(15) = character.EquippedItems.Slots.Trinket2.Name
                weap_icon(15) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Trinket2.Icon + ".jpg"
                weap_id(15) = character.EquippedItems.Slots.Trinket2.ID
            Catch
            End Try
            'Set mainhand
            Try
                weap_name(16) = character.EquippedItems.Slots.MainHand.Name
                weap_icon(16) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.MainHand.Icon + ".jpg"
                weap_id(16) = character.EquippedItems.Slots.MainHand.ID
            Catch
            End Try
            'Set offhand
            Try
                weap_name(17) = character.EquippedItems.Slots.OffHand.Name
                weap_icon(17) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.OffHand.Icon + ".jpg"
                weap_id(17) = character.EquippedItems.Slots.OffHand.ID
            Catch
            End Try
            'Set ranged
            Try
                weap_name(18) = character.EquippedItems.Slots.Ranged.Name
                weap_icon(18) = "http://eu.wowarmory.com/wow-icons/_images/64x64/" + character.EquippedItems.Slots.Ranged.Icon + ".jpg"
                weap_id(18) = character.EquippedItems.Slots.Ranged.ID
            Catch
            End Try
        Catch
        End Try
    End Sub

    Private Sub show_armory()
        picHead.ImageLocation = weap_icon(0)
        Application.DoEvents()
        picNeck.ImageLocation = weap_icon(1)
        Application.DoEvents()
        picShoulder.ImageLocation = weap_icon(2)
        Application.DoEvents()
        picBack.ImageLocation = weap_icon(3)
        Application.DoEvents()
        picChest.ImageLocation = weap_icon(4)
        Application.DoEvents()
        picShirt.ImageLocation = weap_icon(5)
        Application.DoEvents()
        picTabard.ImageLocation = weap_icon(6)
        Application.DoEvents()
        picWrist.ImageLocation = weap_icon(7)
        Application.DoEvents()
        picHand.ImageLocation = weap_icon(8)
        Application.DoEvents()
        picWaist.ImageLocation = weap_icon(9)
        Application.DoEvents()
        picLegs.ImageLocation = weap_icon(10)
        Application.DoEvents()
        picFeet.ImageLocation = weap_icon(11)
        Application.DoEvents()
        picFinger1.ImageLocation = weap_icon(12)
        Application.DoEvents()
        picFinger2.ImageLocation = weap_icon(13)
        Application.DoEvents()
        picTrinket1.ImageLocation = weap_icon(14)
        Application.DoEvents()
        picTrinket2.ImageLocation = weap_icon(15)
        Application.DoEvents()
        picMainHand.ImageLocation = weap_icon(16)
        Application.DoEvents()
        picOffHand.ImageLocation = weap_icon(17)
        Application.DoEvents()
        picRanged.ImageLocation = weap_icon(18)
        Application.DoEvents()
    End Sub

    Sub clear()
        Dim x As Integer
        lnkinfo.Text = ""
        picBack.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picChest.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picClass.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picFeet.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picFinger1.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picFinger2.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picHand.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picHead.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picLegs.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picNeck.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picRace.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picShirt.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picShoulder.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picTabard.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picTrinket1.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picTrinket2.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picWaist.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picWrist.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picMainHand.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picOffHand.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        picRanged.ImageLocation = "http://i40.tinypic.com/vhbz43.jpg"
        WebBrowser1.Visible = False
        WebBrowser2.Visible = False
        lblHealth.Text = "Health:"
        lblSpell.Text = "Mana:"
        lblGuild.Text = "Guild:"
        lblLevel.Text = "Level:"
        txtName.Text = ""
        ProgressBar1.Value = 0
        lblAchieve.Text = "Achievements:"
        ProgressBar2.Value = 0
        ToolStripLabel6.Text = ""
        lblStrength.Text = "Strength:"
        lblAgility.Text = "Agility:"
        lblStamina.Text = "Stamina:"
        lblIntellect.Text = "Intellect:"
        lblSpirit.Text = "Spirit:"
        lblArmor.Text = "Armor:"

        Label3.Text = ""
        Label4.Text = ""

        lblDamageRanged.Text = "Damage: "
        lblSpeed.Text = "Speed: "
        lblPower.Text = "Power: "
        lblHitRatingRanged.Text = "Hit Rating: "
        lblCritChanceRanged.Text = "Crit Chance: "
        'Spell Statistics
        lblDamage.Text = "Bonus Damage: "
        lblHealing.Text = "Bonus Healing: "
        lblHit.Text = "Hit Rating:"
        lblCrit.Text = "Crit Chance: "
        lblHaste.Text = "Haste Rating: "
        lblMana.Text = "Mana Regen: "
        'Defense Statistics
        lblArmorDef.Text = "Armor: "
        lblDefense.Text = "Defense: "
        lblDodge.Text = "Dodge: "
        lblParry.Text = "Parry: "
        lblBlock.Text = "Block: "
        lblResilience.Text = "Resilience: "
        'Melee Statistics
        lblDamageMelee.Text = "Damage: "
        lblSpeedMelee.Text = "Speed: "
        lblPowerMelee.Text = "Power: "
        lblHitRatingMelee.Text = "Hit Rating: "
        lblCritChanceMelee.Text = "Crit Chance: "
        lblExpertise.Text = "Expertise: "

        tslblOperation.Text = ""
        comboRegion.SelectedIndex = 0
        comboEU.SelectedIndex = 0
        comboUSA.SelectedIndex = 0
        txtName.Focus()
        picHorde.Visible = False
        picAlliance.Visible = False
        For x = 0 To 20
            weap_name(x) = ""
            weap_icon(x) = ""
            weap_id(x) = 0
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        AboutBox1.Show()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        load_sheet = False
        clear()
    End Sub

    Private Sub lnkinfo_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
    End Sub

    Private Sub lnkCharSheet_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
        Form2.WebBrowser1.Navigate(char_sheet)
        Form2.Show()
    End Sub

    Private Sub radioEU_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        comboEU.Visible = True
        comboUSA.Visible = False
    End Sub

    Private Sub RadioUSA_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        comboEU.Visible = False
        comboUSA.Visible = True
        comboUSA.SelectedIndex = 0
    End Sub

    Sub create_html(ByVal realm As String, ByVal ch_name As String, ByVal server As Integer)
        Dim data(12) As String
        Dim datafile As StreamWriter = New StreamWriter("character-create.html")
        Dim count As Short

        If server = RegionEnum.USA Then
            regionstr = "http://www.wowarmory.com/character-model-embed.xml?r=" & Trim(realm) & "&cn=" & Trim(ch_name) & "&rhtml=true"
        ElseIf server = RegionEnum.Europe Then
            regionstr = "http://eu.wowarmory.com/character-model-embed.xml?r=" & Trim(realm) & "&cn=" & Trim(ch_name) & "&rhtml=true"
        End If
        data(0) = "<html>"
        data(1) = "<head>"
        data(2) = "<title></title>"
        data(3) = "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">"
        data(4) = "</head>"
        data(5) = "<body bgcolor=""Black"">"
        data(6) = "<iframe src=""" & regionstr & "scrolling=""no"" height=""588"" width=""321"" frameborder=""0""></iframe>"
        data(7) = "</body>"
        data(8) = "</html>"
        For count = 0 To 8
            datafile.WriteLine(data(count))
        Next
        datafile.Close()
        WebBrowser1.Navigate(Application.StartupPath & "\character-create.html")
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
        Form2.WebBrowser1.Navigate("http://sites.google.com/site/wowviewer/")
        Form2.Show()
    End Sub

    Private Sub btnGo_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
        If Trim(txtName.Text) = "" Then
            clear()
            txtName.Focus()
            Exit Sub
        End If
        txtName.Text = StrConv(txtName.Text, VbStrConv.ProperCase)
        file_char_name = Trim(txtName.Text)
        If comboRegion.SelectedIndex = 0 Then
            comboEU.Visible = True
            char_realm = Trim(comboEU.SelectedItem)
            reg_click = 0
        End If
        If comboRegion.SelectedIndex = 1 Then
            comboUSA.Visible = True
            char_realm = Trim(comboUSA.SelectedItem)
            reg_click = 1
        End If
        get_character_information()
    End Sub

    Private Sub picHead_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picHead.Click
        If weap_id(0) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(0))
    End Sub

    Private Sub picneck_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picNeck.Click
        If weap_id(1) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(1))
    End Sub

    Private Sub picshoulder_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picShoulder.Click
        If weap_id(2) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(2))
    End Sub

    Private Sub picBack_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picBack.Click
        If weap_id(3) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(3))
    End Sub

    Private Sub picChest_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picChest.Click
        If weap_id(4) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(4))
    End Sub

    Private Sub picShirt_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picShirt.Click
        If weap_id(5) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(5))
    End Sub

    Private Sub picTabard_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picTabard.Click
        If weap_id(6) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(6))
    End Sub

    Private Sub picWrist_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picWrist.Click
        If weap_id(7) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(7))
    End Sub

    Private Sub picHand_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picHand.Click
        If weap_id(8) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(8))
    End Sub

    Private Sub picWaist_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picWaist.Click
        If weap_id(9) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(9))
    End Sub

    Private Sub picLegs_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picLegs.Click
        If weap_id(10) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(10))
    End Sub

    Private Sub picFeet_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picFeet.Click
        If weap_id(11) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(11))
    End Sub

    Private Sub picFinger1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picFinger1.Click
        If weap_id(12) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(12))
    End Sub

    Private Sub picFinger2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picFinger2.Click
        If weap_id(13) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(13))
    End Sub

    Private Sub picTrinket1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picTrinket1.Click
        If weap_id(14) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(14))
    End Sub

    Private Sub picTrinket2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picTrinket2.Click
        If weap_id(15) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(15))
    End Sub

    Private Sub picMainHand_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picMainHand.Click
        If weap_id(16) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(16))
    End Sub

    Private Sub picOffHand_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picOffHand.Click
        If weap_id(17) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(17))
    End Sub

    Private Sub picRanged_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picRanged.Click
        If weap_id(18) = 0 Then
            Exit Sub
        End If
        WebBrowser2.Navigate("http://wow.allakhazam.com/ihtml?" & weap_id(18))
    End Sub

    Private Sub lnkCharSheet_LinkClicked_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
        Form2.WebBrowser1.Navigate(char_sheet)
        Form2.Show()
    End Sub

    Private Sub ToolStripLabel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel1.Click
        AboutBox1.Show()
    End Sub

    Private Sub ToolStripLabel2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel2.Click
        Application.Exit()
    End Sub

    Private Sub ToolStripLabel3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel3.Click
        Form2.WebBrowser1.Navigate("http://sites.google.com/site/wowviewer/")
        Form2.Show()
    End Sub

    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
        Form3.Show()
        Form3.WebBrowser1.Navigate("http://sites.google.com/site/wowviewer/home/help")
    End Sub

    Private Sub ToolStripLabel4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel4.Click
        Form5.Show()
    End Sub

    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        Dim oReader As StreamReader
        load_sheet = False
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            oReader = New StreamReader(OpenFileDialog1.FileName)
            file_char_name = Trim(oReader.ReadLine)
            file_char_region = Trim(oReader.ReadLine)
            file_char_realm = Trim(oReader.ReadLine)
            oReader.Close()
            clear()
            reg_click = file_char_region
            load_sheet = True
            If file_char_region = 0 Then
                comboEU.Visible = True
                comboUSA.Visible = False
                comboEU.SelectedIndex = file_char_realm
                char_realm = Trim(comboEU.SelectedItem)
            ElseIf file_char_region = 1 Then
                comboEU.Visible = False
                comboUSA.Visible = True
                comboUSA.SelectedIndex = file_char_realm
                char_realm = Trim(comboUSA.SelectedItem)
            End If
            get_character_information()
        End If
    End Sub

    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        Dim oWriteFile As StreamWriter
        If Trim(txtName.Text) = "" Then
            txtName.Focus()
            Exit Sub
        End If
        file_char_name = Trim(txtName.Text)
        file_char_region = reg_click
        If comboRegion.SelectedIndex = 0 Then
            file_char_realm = comboEU.SelectedIndex
        End If
        If comboRegion.SelectedIndex = 1 Then
            file_char_realm = comboUSA.SelectedIndex
        End If
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            oWriteFile = New StreamWriter(SaveFileDialog1.FileName & ".vcf", True)
            oWriteFile.WriteLine(Trim(file_char_name))
            oWriteFile.WriteLine(Trim(file_char_region))
            oWriteFile.WriteLine(Trim(file_char_realm))
            oWriteFile.Close()
        End If
    End Sub

    Private Sub ToolStripLabel5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel5.Click
        Form4.Show()
    End Sub

    Private Sub ToolStripLabel6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel6.Click
        Form2.WebBrowser1.Navigate(char_sheet)
        Form2.Show()
    End Sub
End Class
